/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.awt.Point;
import java.util.ArrayList;

/**
 *
 * @author Morten
 */
public class Pawn extends ChessPiece1 {

    private Point position;
    private boolean color;

    public Pawn(String name, boolean color, Point position) {
	super(name, color, position);
	this.position = position;
	this.color = color;
    }

    @Override
    public ArrayList<Point> possibleMoves() {
	ArrayList<Point> possibleMoves;
	possibleMoves = new ArrayList<>();
	boolean test;
	for (int i = 0; i < 9; i++) {
	    for (int j = 0; i < 9; j++) {
		test = false;
		if ((i == position.getX() && j != position.getY())) {
		    if (color) {
			if ((position.getX() == 7 && i > position.getX() - 3 && i < position.getX()) || (i == position.getX() - 1)) {
			    test = true;
			}
		    } else {
			if ((position.getX() == 2 && i < position.getX() + 3 && i > position.getX()) || (i == position.getX() + 1)) {
			    test = true;
			}
		    }
		    if (canMoveTo(i, j) && test) {
			possibleMoves.add(new Point(i, j));
		    }
		}

	    }

	}
	return possibleMoves;
    }
}
